package sjtu.ist.warehouse4ws.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;


import sjtu.ist.warehouse4ws.model.Department;
import sjtu.ist.warehouse4ws.model.Rolepermissions;
import sjtu.ist.warehouse4ws.service.RolepermissionsService;


import com.googlecode.jsonplugin.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

public class ShowRolepermissions extends ActionSupport{
	private List <Rolepermissions> rpList=new ArrayList<Rolepermissions> ();
	private RolepermissionsService rpService;
	
	private String id;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setRolepermissionsService(RolepermissionsService rpService) {
		this.rpService = rpService;
	}
	
	public String showRolepermissions(){
		HttpServletRequest request = ServletActionContext.getRequest ();
		this.id=request.getParameter("cid");
		this.rpList=rpService.getRolepermissionsById(id);
		System.out.print(rpList.size());
		return SUCCESS;
	}
	
	@JSON(name="totalRolepermissions")	
	public int getTotalRolepermissions() {
		return this.rpList.size();
	}
    
	@JSON(name="Rolepermissions")	
	public List<Rolepermissions> getRolepermissionsList() {
		return this.rpList;
	}

}
